# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/9 19:22
# @Author   : Robot-Zsj
"""
description:

input
0,1,4,3,1,0,0,1,2,3,1,2,1,0
13
output
3
"""
heights = list(map(int, input().split(",")))
strength = int(input())


def climb(idxs, direction):
    j = 0

    while j < len(heights) and heights[j] != 0:
        j += 1

    cost = 0

    for i in range(j + 1, len(heights)):
        if heights[i] == 0:
            cost = 0
            continue

        diff = heights[i] - heights[i - 1]

        if diff > 0:
            cost += diff * 3

            if i + 1 >= len(heights) or heights[i] > heights[i + 1]:
                if cost < strength:
                    if direction:
                        idxs.add(i)
                    else:
                        idxs.add(len(heights) - i - 1)
        elif diff < 0:
            cost -= diff * 3


def getResult():
    idxs = set()

    climb(idxs, True)

    heights.reverse()

    climb(idxs, False)

    return len(idxs)


print(getResult())
